<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body {
            min-height: 100vh;
            background-color: #abefe9;
        }

        body>div {
            margin: 5px;
            border: #bfa 3px solid;
            background-color: #FFCCCC;
        }

        hr {
            background-color: red;
            height: 1px;
            border: 0;
        }

        .d1 {
            height: 50vh;
            width: 100px;
        }

        .d21 {
            height: 100px;
            width: 100px;
            background-color: #ccf;
            /* 只设置固定定位时，位置不会发生改变
                元素脱离文档流
                宽度由内容撑开
                元素以视口左上角为原点定位，不会随网页滚动条移动
             */
            position: fixed;

            top: 50px;
            left: 50px;
        }

        .d22 {
            height: 100px;
            width: 100px;
            background-color: #28e;
        }
    </style>
</head>

<body>
    <div class="d1"></div>
    <div class="d2">
        <div class="d21"></div>
        <div class="d22"></div>
    </div>
    <div class="d1"></div>

</body>

</html>